/**
 * store
 *
 * @author yuanchen
 * @date 2021-10-30 22:57
 */
package store.algorithm.factory;

import store.Item;
import store.algorithm.AbstarctItemChangeValueAlgorithm;
import store.algorithm.enums.ItemTypeEnum;
import store.algorithm.impl.*;

import java.util.HashMap;
import java.util.Map;

/**
 * 商品值变化工厂
 * @author yuanchen
 * @date 2021-10-30 22:57
 */
public class ItemChangeValueAlgorithmFactory {

    /**商品属性变化算法集合*/
    private static Map<ItemTypeEnum, AbstarctItemChangeValueAlgorithm> algorithmMap=new HashMap<>();
    static {
        algorithmMap.put(ItemTypeEnum.AGED_WINE,new AgedWineItemChangeValueAlgorithm());
        algorithmMap.put(ItemTypeEnum.SULFURAS,new SulfurasItemChangeValueAlgorithm());
        algorithmMap.put(ItemTypeEnum.SHOW_TICKET,new ShowTicketItemChangeValueAlgorithm());
        algorithmMap.put(ItemTypeEnum.CURE,new CureItemChangeValueAlgorithm());
        algorithmMap.put(ItemTypeEnum.DEFAULT,new DefaultItemChangeValueAlgorithm());
    }

    /**
     * 获取商品属性变化算法实现
     * @return
     */
    public static AbstarctItemChangeValueAlgorithm getItemChangeValueAlgorithmService(Item item){
        ItemTypeEnum itemType=null;
        if(item.name==null||"".equals(item.name)){
            itemType=ItemTypeEnum.DEFAULT;
        }else {
            itemType=ItemTypeEnum.find(item.name);
        }
        return algorithmMap.get(itemType);
    }




}
